package com.car.dal.dao.office;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.car.bean.GridObj;
import com.car.bean.OrderObj;
import com.car.bean.PageObj;
import com.car.dal.dao.ibatis.IbatisCommonDao;
import com.car.dal.object.TgClient;
import com.car.dal.object.TgOffice;
import com.car.dal.object.TgReserve;
import com.car.dal.object.TgUserinfo;
import com.car.util.Page;

public class TgOfficeDaoImpl extends IbatisCommonDao<TgOffice, Long> implements TgOfficeDao {

	public GridObj GetList(TgOffice tgOffice, PageObj pageObj) {
		OrderObj order = new OrderObj();
		order.setDir("asc");
		order.setSort("id");
		// TODO Auto-generated method stub
		return super.findByPage(tgOffice, pageObj, order);
	}
	
	@Override
	public Integer getCenterZonji(TgOffice tgOffice) {
		return this.queryForInteger("getCenterZonji", tgOffice);
	}

	@Override
	public Double getCenterMerchant(String yearAgo,String currentDate,String region,Integer state) {
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("yearAgo", yearAgo);
		args.put("currentDate", currentDate);
		args.put("region", region);
		args.put("state", state);
		return Double.valueOf( getSqlMapClientTemplate().queryForObject("getCenterMerchant", args).toString());

	}

	@Override//中心到访记录
	public Integer getCenterTotal(TgOffice tgOffice) {
		return this.queryForInteger("getCenterTotal", tgOffice);
	}

	@Override
	public Integer getCenterNot(TgOffice tgOffice) {
		return this.queryForInteger("getCenterNot", tgOffice);
	}

	@Override
	public Integer getCenterReal(TgOffice tgOffice) {
		return this.queryForInteger("getCenterReal", tgOffice);
	}
	
	@Override
	public List<TgOffice> getOfficeName(TgOffice tgOffice) {
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName", tgOffice);
		return list;
	}
	
	@Override
	public List<TgOffice> getOfficeName2(TgOffice tgOffice) {
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName2", tgOffice);
		return list;
	}

	@Override
	public List<TgOffice> getCoreNameByCity(String cityName) {
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("cityName", cityName);
		List<TgOffice> a = null;
			try {
			 a =getSqlMapClientTemplate().queryForList("getCoreNameByCity", args);
		}catch (Exception e){
			e.printStackTrace();
		}

		return a;
	}
	
	@Override
	public List<TgOffice> getCoreNameByCity2(TgOffice tgOffice) {
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName3", tgOffice);
		return list;
	}
	
	@Override
	public Double getCurrentCityMerchant(String startDate, String endDate, String keynames, Integer state){
		Map<String, Object> args = new HashMap<String, Object>();
		args.put("startDate", startDate);
		args.put("endDate", endDate);
		args.put("keynames", keynames);
		args.put("state", state);
		return Double.valueOf( getSqlMapClientTemplate().queryForObject("getCurrentCityMerchant", args).toString());

	}

	@Override
	public List<TgOffice> getcentersByType(TgOffice office,  Page page) {
		office.setFirstrownum(page.getFirstrownum());
		office.setPagesize(page.getPagesize());
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName4", office);
		return list;
	}

	@Override
	public Integer getCentercount(TgOffice office) {
		return this.queryForInteger("getCentercount", office);
	}

	@Override
	public List<TgOffice> findByName(TgOffice office2) {
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName5", office2);
		return list;
	}
	/**
	 * 获取所有的中心
	 */
	@Override
	public List<TgOffice> getAll_Tg_office() {
		return findAll(TgOffice.class);
	}

	@Override
	public List<TgOffice> getCoreNameByCity3(TgOffice office) {
		List<TgOffice> list=this.queryForEntityList(TgOffice.class,"getOfficeName31", office);
		return list;
	}

	@Override
	public List<TgOffice> getOfficeNameByProvince(String province) {
		TgOffice office = new TgOffice();
		office.setProvince(province);
		return this.queryForEntityList(TgOffice.class,"getOfficeNameByProvince", office);
	}

}
